#include <cstdlib>
#include <iostream>
#include <math.h>
#define e 0.0001
using namespace std;
 
int fact(double x) {
 int y=1;
 for (int k = 1; k <= x; k ++)
 y=y*k;
 return y;
}
 
float f(float x){
 float F;
 for (int k = 0; k <= 10; k ++)
 { 
 F+=pow(-1,k)*(((float)(fact(19-k)))/((float)(fact(k)*fact(20-2*k))))* pow(4* pow(x,2),10-k);
 }
 return F*10;}
 
float f1(float x){
 float F;
 for (int k = 0; k <= 10; k ++)
 { 
 F+=pow(-1,k)*(((float)(fact(19-k)))/((float)(fact(k)*fact(20-2*k))))*pow(4,10-k)*2*(10-k)* pow(x,2*(10-k)-1);
 }
 return F*10;}
 
float f2(float x){
 float F;
 for (int k = 0; k <= 10; k ++)
 { 
 F+=pow(-1,k)*(((float)(fact(19-k)))/((float)(fact(k)*fact(20-2*k))))*pow(4,10-k)*2*(10-k)*(2*(10-k)-1)* pow(x,2*(10-k)-2);
 }
 return F*10;}
 
float kos()
{ float a,b,x,dx;
int k=0;
if (f(a)*f2(a)>0) {
    dx=b;
}
else dx=a;
do {
    dx-=f(dx)/f1(dx);
        k++;
 }
 while (fabs(f(dx))>= e);
return dx;
}
 int main() {
    float a,b,x;
    int k=0;
cout<<("Vvedite a: ");
cin>>a;
cout<<("Vvedite b: ");
cin>>b;
cout<<(" metod kasatelnuh");
x=kos();
cout<<("\nZnachenie kornya na zadannom promejutke = ")<<x;
cout<<("\nKollichestvo iteracui = ")<<k;
                system("PAUSE");
        return 0;
}
